package cn.groupmarket.domain.activity.service.trial.thread;

import cn.groupmarket.domain.activity.adapter.repository.IActivityRepository;
import cn.groupmarket.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.groupmarket.domain.activity.model.valobj.SCSkuActivityVO;

import javax.annotation.Resource;
import java.util.concurrent.Callable;

public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {


    private final String source;
    private final String channel;
    private final String productId;
    private final IActivityRepository repository;


    public QueryGroupBuyActivityDiscountVOThreadTask(String source, String channel, String productId, IActivityRepository repository) {
        this.source = source;
        this.channel = channel;
        this.productId = productId;
        this.repository = repository;
    }

    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        SCSkuActivityVO skuActivityVO = repository.querySCSkuActivityBySCGoodsId(source,channel,productId);
        if(skuActivityVO == null){return null;}
        return repository.queryGroupBuyActivityDiscountVO(skuActivityVO.getActivityId());
    }
}
